﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace ServiciosProductos
{
    // NOTA: puede usar el comando "Rename" del menú "Refactorizar" para cambiar el nombre de clase "Service1" en el código, en svc y en el archivo de configuración.
    public class ServiceProductos : IServiceProductos
    {
        Ecommerce bd = new Ecommerce();
        public Product getProductById(long id)
        {
            var consulta = bd.Product.Single(p => p.ProductId == id);
            
            return consulta;
        }

        public List<Product> getProductByName(string name)
        {
            var consulta = from p in bd.Product
                           where p.Name.Contains(name)
                           select p;
            return consulta.ToList();
        }

        public List<Product> getProductByShow(string show)
        {
            var consulta = from p in bd.Product
                           where p.Show.Contains(show)
                           select p;
            return consulta.ToList();
        }

        /////////////////////////////////

        public List<AccommodationRate> getAccommodationRate()
        {
            var consulta = from a in bd.AccommodationRate
                           select a;
            return consulta.ToList();
        }

        public List<City> getCity()
        {
            var consulta = from c in bd.City
                           select c;
            return consulta.ToList();
        }

        public List<CityRate> getCityRate()
        {
            var consulta = from cr in bd.CityRate
                           select cr;
            return consulta.ToList();
        }

        public List<ShowRate> getShowRate()
        {
            var consulta = from sr in bd.ShowRate
                           select sr;
            return consulta.ToList();
        }

        public List<TransportationRate> getTransportationRate()
        {
            var consulta = from tr in bd.TransportationRate
                           select tr;
            return consulta.ToList();
        }
    }
}
